﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Data;

namespace AbetEvaluation.Business
{
    public partial class Outcomes : Component
    {
        public Outcomes()
        {
            InitializeComponent();
        }

        public Outcomes(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        public static DataTable GetOutcomes()
        {
            Data.DataSet1TableAdapters.abet_OutcomesTableAdapter adapter = new Data.DataSet1TableAdapters.abet_OutcomesTableAdapter();
            Data.DataSet1.abet_OutcomesDataTable table = adapter.GetOutcomes();
            return table;
        }

        public static DataTable GetOutcome(Guid outcomeID)
        {
            Data.DataSet1TableAdapters.abet_OutcomesTableAdapter adapter = new Data.DataSet1TableAdapters.abet_OutcomesTableAdapter();
            Data.DataSet1.abet_OutcomesDataTable table = adapter.GetOutcome(outcomeID);
            return table;
        }

        public static int InsertOutcome(Outcome o)
        {
            Data.DataSet1TableAdapters.abet_OutcomesTableAdapter adapter = new Data.DataSet1TableAdapters.abet_OutcomesTableAdapter();
            int result = adapter.InsertOutcome(o.ID, o.Title, o.Description, o.CreatedBy);
            return result;
        }

        public static int UpdateOutcome(Outcome o)
        {
            Data.DataSet1TableAdapters.abet_OutcomesTableAdapter adapter = new Data.DataSet1TableAdapters.abet_OutcomesTableAdapter();
            int result = adapter.UpdateOutcome(o.Title, o.Description, o.ID);
            return result;
        }

        public static int DeleteOutcome(Outcome o)
        {
            //delete questions.
            Data.DataSet1TableAdapters.abet_QuestionsTableAdapter questionsAdapter = new Data.DataSet1TableAdapters.abet_QuestionsTableAdapter();
            questionsAdapter.DeleteQuestions(o.ID);

            //delete rubrics.
            Data.DataSet1TableAdapters.abet_RubricsTableAdapter rubricsAdapter = new Data.DataSet1TableAdapters.abet_RubricsTableAdapter();
            rubricsAdapter.DeleteRubrics(o.ID);

            //delete outcome.
            Data.DataSet1TableAdapters.abet_OutcomesTableAdapter outcomeAdapter = new Data.DataSet1TableAdapters.abet_OutcomesTableAdapter();
            int result = outcomeAdapter.DeleteOutcome(o.ID);
            
            return result;
        }
    }
}
